import axios from "axios";

class Http{
    instance;
    constructor(config){
        this.instance = axios.create(config);
        this.instance.interceptors.request.use(
            (config) => {
                return config;
            },
            (error)=>{
                return Promise.reject(error);
            }
        )
        this.instance.interceptors.response.use(
            (res) => {
                return res;
            },
            (error)=>{
                return Promise.reject(error);
            }
        )
    }
    get(config){
        return this.instance.request({...config,method:"GET"});
    }
    post(config){
        return this.instance.request({...config,method:"POST"});
    }
    put(config){
        return this.instance.request({...config,method:"PUT"});
    }
    delete(config){
        return this.instance.request({...config,method:"DELETE"});
    }

}

export default Http;